<?php
/**
 * Created by PhpStorm.
 * User: jacklove
 * Date: 2019/5/17
 * Time: 15:04
 */

namespace app\wxapi\controller;

use think\Db;
use think\Request;
use think\Controller;

class Nocommon extends Controller
{
    public function _initialize()
    {
        $post = Request::instance()->post();
        file_put_contents('sign.txt',json_encode($post));

     }


    /**
     * 接口返回封装
     */
    protected function apiReturn($code='-1',$msg,$data=[]){
        $code = (string)$code;
        if($code == '-1'){
            exit('参数调用错误');
        }
        if(empty($data)){
            if($code=='200'){
                exit(json_encode(array('code'=>$code,'msg'=>$msg,'data'=>$data)));
            }else{
                exit(json_encode(array('code'=>$code,'msg'=>$msg)));
            }
        }else{
            exit(json_encode(array('code'=>$code,'msg'=>$msg,'data'=>$data)));
        }
    }
    
    /*
     * 接口分页类
     */
    protected function p()
    {
        //客户端传过来的分页数字
        $p = input('page',1,'intval');
        if($p < 1){
            $p = 1;
        }
        return $p;
    }

}